.\" Copyright (c) 1985, 1991, 1993, 1994
.\"     The Regents of the University of California.  All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\"    may be used to endorse or promote products derived from this software
.\"    without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.Dd November 9, 2012
.Dt MUDDOG 8
.Os
.Sh NAME
.Nm muddog
.Nd process
.Dq super-server
.Sh SYNOPSIS
.Nm
.Op Fl d
.Op Fl P Ar filename
.Op Fl v
.Op Ar configuration file
.Sh DESCRIPTION
The
.Nm
utility a simple utility to monitor and manage processes for
High Availability.
It launches specified server application based on configuration
and restore the process when it's aborted abnormally.
.Pp
The following options are available:
.Bl -tag -width indent
.It Fl d
Turn on debugging.
.It Fl P
Specify an alternate file in which to store the process ID.
.It Fl v
Show the version.
.El
.Pp
Upon execution,
.Nm
reads its configuration information from a configuration
file which, by default, is
.Pa /etc/muddog.conf .
There must be an entry for each field of the configuration
file, with entries for each field separated by a tab or
a space.
Comments are denoted by a
.Dq #
at the beginning
of a line.
There must be an entry for each field.
The
fields of the configuration file are as follows:
.Pp
.Bd -unfilled -offset indent -compact
service-name
user[:group]
server-program
server-program-arguments
.Ed
.Pp
The
.Em service-name
entry is an identifier to specify the entry.
.Pp
The
.Em user
entry should contain the user name of the user as whom the server
should run.
This allows for servers to be given less permission
than root.
The optional
.Em group
part separated by
.Dq \&:
allows a group name other
than the default group for this user to be specified.
.Pp
The
.Em server-program
entry should contain the pathname of the program which is to be
executed by
.Nm
when the program is launched or SIGHUP signal is received.
Please note that server-program should not call
.Xr daemon 3
function internally because
.Nm
will execute server-program again due to SIGCHLD signal got.
.Pp
The
.Em server-program-arguments
entry lists the arguments to be passed to the
.Em server-program ,
starting with argv[0], which usually is the name of
the program.
.Pp
.Sh "FILES"
.Bl -tag -width /var/run/inetd.pid -compact
.It Pa /etc/muddog.conf
configuration file
.Nm
.El
.Sh "EXAMPLES"
Here are several example service entries for the various types of services:
.Bd -literal
varnishd root  /usr/sbin/varnishd  varnishd -F
.Ed
.Sh "ERROR MESSAGES"
The
.Nm
server
logs error messages using
.Xr syslog 3 .
Important error messages and their explanations are:
.Pp
.Bl -ohang -compact
.It Xo
.Ar service :
.No \&No such user
.Ar user ,
.No service ignored
.Xc
.It Xo
.Ar service :
.No getpwnam :
.Ar user :
.No \&No such user
.Xc
No entry for
.Ar user
exists in the
.Xr passwd 5
database.
The first message
occurs when
.Nm
(re)reads the configuration file.
The second message occurs when the
service is invoked.
.Pp
.It Xo
.Ar service :
.No can't set uid
.Ar uid
.Xc
.It Xo
.Ar service :
.No can't set gid
.Ar gid
.Xc
The user or group ID for the entry's
.Ar user
field is invalid.
.El
.Sh HISTORY
The
.Nm
utility written based on FreeBSD
.Xr inetd 8 .

